import type * as T from './type'
import http from '@/utils/http'

export type * from './type'

/**
 * Job列表
 * @param query
 */
export function listJob(query: T.JobPageQuery) {
  return http.post<T.JobResp[]>(`/scheduler/job/list`, query)
}

/**
 * Job分页
 * @param query
 */
export function pageJob(query: T.JobPageQuery) {
  return http.post<PageRes<T.JobResp[]>>(`/scheduler/job/page`, query)
}

/**
 * 获取所有可用的Job类
 */
export function listJobClass() {
  return http.get<string[]>(`/scheduler/job/class/list`)
}

/**
 * 新增Job
 * @param data
 */
export function addJob(data: any) {
  return http.post(`/scheduler/job/create`, data)
}

/**
 * 更新Job
 * @param id
 * @param data
 */
export function updateJob(id: number, data: any) {
  return http.put(`/scheduler/job/update/${id}`, data)
}

/**
 * 暂停Job
 * @param id
 */
export function pauseJob(id: number) {
  return http.put(`/scheduler/job/pause/${id}`)
}

/**
 * 恢复Job
 * @param id
 */
export function resumeJob(id: number) {
  return http.put(`/scheduler/job/resume/${id}`)
}

/**
 * 执行Job
 * @param id
 */
export function executeJob(id: number) {
  return http.put(`/scheduler/job/execute/${id}`)
}

/**
 * 删除Job
 * @param id
 */
export function deleteJob(id: number) {
  return http.del(`/scheduler/job/delete/${id}`)
}
